package com.ktg.mes.util;

import javax.servlet.http.HttpServletRequest;

/**
 * @author dzh
 * @version 1.0
 * @date 2022/7/26 14:18
 */
public class TokenUtils {

    /**
     * 获取 request 里传递的 token
     *
     * @param request
     * @return
     */
    public static String getTokenByRequest(HttpServletRequest request) {
        String parameter = request.getParameter("token");
        String header = request.getHeader("X-Access-Token");
        if (parameter == null && header == null) {
            parameter = request.getHeader("Authorization");
        }
        return parameter != null ? parameter : header;
    }

}
